<template>
  <div id="app">
    <img alt="Vue logo" src="./assets/logo.png" />
    <HelloWorld
      msg="Welcome to Your Vue.js App"
      :count="parentCount"
      @child-change-event="appHandler"
    ></HelloWorld>
    <!-- 父组件在子组件标签上绑定自定义事件来监听与接收子组件传递的数据。 -->
    <h1>父组件里面的getChildData的数据为：{{ getChildData }}</h1>
    <hr>
    <!-- 接收插槽传递的数据 -->
    <HelloWorld> Hello标签的文本1
      <template #foot="dataObj">foot= {{dataObj}},内容是= {{dataObj.childCount}}</template>
    </HelloWorld> <hr>
    <!-- 或者你直接通过解构方式也行 -->
    <HelloWorld> Hello标签的文本22
      <template #foot="{childCount}">foot= {{childCount}}</template>
    </HelloWorld> <hr>
    <HelloWorld></HelloWorld><hr>

  </div>
</template>

<script>
import HelloWorld from "./components/HelloWorld.vue";

export default {
  name: "App",
  components: {
    HelloWorld,
  },
  data() {
    return {
      parentCount: 150,
      getChildData: 2,
    };
  },
  methods: {
    //appHandler监听子组件传递的数据
    appHandler(childCount) {
      this.getChildData = childCount;
    },
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
